Purpose of This Document


Working with 2017-18 benthic invertebrate data to calculate and plot:

Sections



Setup


Do some basic math to calculate density of each taxon…

#Calculations...
bugs$Density <- bugs$Count / bugs$PercentSub / .09

bugs$CollDate <- as.Date(bugs$CollDate, format = "%m/%d/%y") %>% year() %>% as.factor()

bugs.agg <- bugs %>%
  group_by(CollDate, Stream, Treatment, Taxon) %>%
  summarise_at(vars(Density), funs(sum)) %>% ungroup

bugs.agg$Density <- bugs.agg$Density / 3

Here we divide Count by percent subsampled (actually a fraction) to get a count for the total sample taken. We then divide by .09 which is the area of the surber sampler (in m\(^2\)). We then aggregate and divide by three (There were three samples taken per reach).

A quick taste of the finished data table product:

Taxa


Plot of density differences between reaches for both 2017 and 2018. As seen, there are no ubiquitous taxa that consistently increase or decrease across streams. Can also see how shitty the plot is, too many taxa…

FFG’s


CF = Collector Filterer, CG = Collector Gatherer, SC = Scrapers (a composite of SCe and SCi), SCe = Scrapers that are edible, SCi = Scrapers that are inedible, P = Predators

CF = Collector Filterer, CG = Collector Gatherer, SC = Scrapers (a composite of SCe and SCi), SCe = Scrapers that are edible, SCi = Scrapers that are inedible, P = Predators

Here we plot density differences of FFG’s.

Notice the only group with consistently elevated differences in the post gap year (2018) is Scrapers.

Here we can see that Collector Gatherers are the most abundant taxa, but the aggregate of the two scraper categories (SCe and SCi) is also up there.

When comparing between the reaches we see elevated abundances of both scraper groups (except for SCi in CHUCK). Collector Gatherers are also consistently elevated (except in CHUCK), which seems contradictory to the between year comparison (Control reach has always had elevated abundances of CG’s?)

  • Will these functional feeding groups be important in diets?

  • Does the relative change in abundance of a taxa group change fish selection (i.e. now that there are more scrapers in the treatment reach are the fish going to town on Scrapers?)

  • TBD. (see other.md file in the Diets project)

Here we see that the Scraper taxa with the greatest change are:

  • Micrasema

  • Juga

  • Glossosoma

  • Drunella

  • Heptageniidae taxa

Two size classes are plotted, small (S) and large (L) based on nothing, just observation… Hopefully I will soon incorporate some information from the Poff database about final larval instar size and have three size classes: small, medium, and large.

NMDS :metal:


Who knows what I’m actually doing, all of this ordination stuff is currently pre BOT 570. I will definitely update all this once I know how to handle singleton taxa, loads of zero’s, etc.

## Square root transformation
## Wisconsin double standardization
## Run 0 stress 0.1726121 
## Run 1 stress 0.1726121 
## ... Procrustes: rmse 1.585086e-05  max resid 2.770769e-05 
## ... Similar to previous best
## Run 2 stress 0.1726121 
## ... Procrustes: rmse 2.167466e-05  max resid 4.965995e-05 
## ... Similar to previous best
## Run 3 stress 0.1726124 
## ... Procrustes: rmse 8.377258e-05  max resid 0.0002704961 
## ... Similar to previous best
## Run 4 stress 0.1726121 
## ... Procrustes: rmse 2.271384e-05  max resid 5.055728e-05 
## ... Similar to previous best
## Run 5 stress 0.1726121 
## ... New best solution
## ... Procrustes: rmse 1.691333e-05  max resid 3.96536e-05 
## ... Similar to previous best
## Run 6 stress 0.1726121 
## ... Procrustes: rmse 2.152572e-05  max resid 4.910963e-05 
## ... Similar to previous best
## Run 7 stress 0.1738211 
## Run 8 stress 0.1726121 
## ... Procrustes: rmse 1.193686e-05  max resid 3.019777e-05 
## ... Similar to previous best
## Run 9 stress 0.1738211 
## Run 10 stress 0.1726121 
## ... New best solution
## ... Procrustes: rmse 8.563446e-06  max resid 2.061213e-05 
## ... Similar to previous best
## Run 11 stress 0.1738211 
## Run 12 stress 0.2696078 
## Run 13 stress 0.1726121 
## ... Procrustes: rmse 2.066431e-05  max resid 4.552775e-05 
## ... Similar to previous best
## Run 14 stress 0.2407868 
## Run 15 stress 0.2647598 
## Run 16 stress 0.1738211 
## Run 17 stress 0.1738212 
## Run 18 stress 0.1726121 
## ... Procrustes: rmse 7.011413e-05  max resid 0.0001616713 
## ... Similar to previous best
## Run 19 stress 0.1726121 
## ... Procrustes: rmse 3.608276e-05  max resid 7.959911e-05 
## ... Similar to previous best
## Run 20 stress 0.1726121 
## ... Procrustes: rmse 1.225301e-05  max resid 2.823399e-05 
## ... Similar to previous best
## *** Solution reached

This is a pretty good stress value, who knows how that will change when I start doing this right… Can see the transfrmations applied at the top of the output, this was done automatically, I wouldn’t know what to do. Used the Bray-Curtis distance metric, max tries is set to 100 with dimensions equal to 2.

The “display” argument can be set to “site” or “species” depending on what you want to group. “kind” can be standard deviation or standard error, not sure which to use here.

# Fit the ellipse function to actual data
df_ell <- data.frame()
for(g in NMDS$YearTreat){
  df_ell <- rbind(df_ell, cbind(as.data.frame(with(NMDS[NMDS$YearTreat == g,],
                  vegan:::veganCovEllipse(ord[[g]]$cov, ord[[g]]$center, ord[[g]]$scale)))
                                ,YearTreat = g))
}

not going to pretend like I know how this works, got it from https://stackoverflow.com/questions/13794419/plotting-ordiellipse-function-from-vegan-package-onto-nmds-plot-created-in-ggplo but I do know that changing the column selected from NMDS changes which variable is used for grouping.

Actually maybe cool result, all of the treatment reaches now plot closer post-gap year. The controls show a similar pattern though maybe a little less pronounced. Everything also shifted left between the two years, although this isn’t because of the treatment, just annual changes. Maybe the gap amplified whatever effect the year had, extra, extra light or temperature maybe.

Summary Info



Session Info:

sessionInfo()
## R version 3.5.1 (2018-07-02)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS  10.14
## 
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] bindrcpp_0.2.2    DT_0.5            viridis_0.5.1    
##  [4] viridisLite_0.3.0 ggthemes_4.0.1    readxl_1.1.0     
##  [7] lubridate_1.7.4   vegan_2.5-2       lattice_0.20-35  
## [10] permute_0.9-4     forcats_0.3.0     stringr_1.3.1    
## [13] dplyr_0.7.5       purrr_0.2.5       readr_1.1.1      
## [16] tidyr_0.8.1       tibble_1.4.2      ggplot2_3.1.0    
## [19] tidyverse_1.2.1  
## 
## loaded via a namespace (and not attached):
##  [1] httr_1.3.1       jsonlite_1.5     modelr_0.1.2     shiny_1.2.0     
##  [5] assertthat_0.2.0 highr_0.7        cellranger_1.1.0 yaml_2.2.0      
##  [9] pillar_1.2.3     backports_1.1.2  glue_1.2.0       digest_0.6.18   
## [13] promises_1.0.1   rvest_0.3.2      colorspace_1.3-2 htmltools_0.3.6 
## [17] httpuv_1.4.5     Matrix_1.2-14    plyr_1.8.4       psych_1.8.4     
## [21] pkgconfig_2.0.1  broom_0.4.4      haven_1.1.1      xtable_1.8-3    
## [25] scales_1.0.0     later_0.7.5      mgcv_1.8-24      withr_2.1.2     
## [29] lazyeval_0.2.1   cli_1.0.0        mnormt_1.5-5     magrittr_1.5    
## [33] crayon_1.3.4     mime_0.6         evaluate_0.10.1  nlme_3.1-137    
## [37] MASS_7.3-50      xml2_1.2.0       foreign_0.8-70   tools_3.5.1     
## [41] hms_0.4.2        munsell_0.5.0    cluster_2.0.7-1  compiler_3.5.1  
## [45] rlang_0.3.0.1    grid_3.5.1       rstudioapi_0.7   htmlwidgets_1.3 
## [49] crosstalk_1.0.0  labeling_0.3     rmarkdown_1.10   gtable_0.2.0    
## [53] reshape2_1.4.3   R6_2.3.0         gridExtra_2.3    knitr_1.20      
## [57] bindr_0.1.1      rprojroot_1.3-2  stringi_1.2.3    parallel_3.5.1  
## [61] Rcpp_1.0.0       tidyselect_0.2.4
 

A work by Cedar Mackaness

cedarmkns@gmail.com